package com.tjc.common.pool;

import java.io.IOException;
import java.util.NoSuchElementException;

/**
 * @Author: tjc
 * @description
 * @Date Created in 21:49 2022-08-04
 */
public abstract class BaseObjectPool<T> implements ObjectPool<T> {

    @Override
    public abstract T borrowObject() throws Exception, NoSuchElementException, IllegalStateException;

    @Override
    public abstract void returnObject(T obj) throws Exception;

    @Override
    public abstract void invalidateObject(T obj) throws Exception;

    @Override
    public void clear() throws UnsupportedOperationException {
        throw new UnsupportedOperationException();
    }

    @Override
    public int getNumActive() {
        return -1;
    }

    @Override
    public int getNumIdle() {
        return -1;
    }

    protected volatile boolean closed;

    @Override
    public void close() throws IOException {
        closed = true;
    }
}
